package com.cslg.ac.demo.dao.post;

import com.cslg.ac.demo.dao.post.po.HostEvaluationPO;
import com.cslg.ac.demo.entity.post.HostEvaluation;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface HostEvaluationDAO {
    String  TABLE_NAME = "r_host_evaluation";
    String  INSERT_FIELDS = "host_id, type, anonymous, evaluation_id";
    String SELECT_FIELDS = "host_id hostId, evaluation_id evaluationId, type, anonymous";

    @Insert({"insert into ", TABLE_NAME, "(", INSERT_FIELDS, ") values(#{hostId}, #{type}, #{anonymous}, #{evaluationId})"})
    void insert(@Param("hostId")int hostId, @Param("type")int type, @Param("anonymous")int anonymous, @Param("evaluationId")int evaluationId);

    @Select({"select ", SELECT_FIELDS, "where host_id = #{hostId}" })
    HostEvaluationPO selectByHostId(@Param("hostId")int hostId);

    @Select({"select ", SELECT_FIELDS, " from ", TABLE_NAME,"where evaluation_id = #{evaluationId}"})
    HostEvaluationPO selectByEvaluationId(@Param("evaluationId")int evaluationId);


    Integer[] sortByCreadit();
}
